package com.wx.leetcode;

/**
 * @desc: 回文数
 * 判断一个整数是否是回文数。回文数是指正序（从左向右）和倒序（从右向左）读都是一样的整数。
 * @author: wx
 * @time: 2020/5/29 4:46 PM
 */
public class PalindromeTopic {

    public static boolean isPalindrome(int x) {

        if (x == 0) {
            return true;
        }

        String str = String.valueOf(x);

        char[] chars = str.toCharArray();

        int length = chars.length;

        int startIndex = 0;
        int endIndex = length - 1;

        while (startIndex < endIndex) {

            if (chars[startIndex] == chars[endIndex]) {
                startIndex++;
                endIndex--;
            } else {
                return false;
            }
        }

        return true;

    }


    public static void main(String args[]) {

        System.out.println(isPalindrome(1132311));

    }


}
